package main;

import graphik.EinfachesFenster;
import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
import java.util.logging.Level;
import java.util.logging.Logger;

public class Main {

    private EinUndAusgabe io = new EinUndAusgabe();
    
    public Main() {
        dialog();
    }

    public void dialog() {
        int eingabe = -1;
        while (eingabe != 0) {
            System.out.println(
                    "Was wollen Sie?\n"
                    + " (0) Programm beenden\n"
                    + " (1) neue Klasse zur Analyse ausw\u00E4hlen");
            eingabe = io.leseInteger();
            switch (eingabe) {
                case 0:
                    break;
                case 1:
                    System.out.print("vollst\u00E4ndiger Klassenname: ");
                    //String klasse = io.leseString();
                    String klasse = "model.Dummy";
            try {
                // TODO
                Class c = Class.forName(klasse);
                Constructor[] cons = c.getDeclaredConstructors();
                EinfachesFenster fenster = new EinfachesFenster();
                fenster.setGroesse(800, 600);
                int actHoehe = 20;
                for(Constructor con : cons) {
                    //con.getName()
                    
                    fenster.schreibe(29, actHoehe+=20, printConstructors(con));
                    //actHoehe+=20;
                }
            } catch (ClassNotFoundException ex) {
                System.out.println("gibts nicht.");
                Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
            }
                    
                    // TODO ENDE
            }
        }
    }
    
    private String printConstructors(Constructor c) {
        StringBuilder out = new StringBuilder();
        
        //Name "abschneiden"
        String name = c.getName();
        name = name.substring(name.lastIndexOf(".")+1);
        
        //Modifier Name zu Symbol
        int modifiers = c.getModifiers();
        switch(modifiers) {
            case 1:
                out.append("+");
                break;
            case 2:
                out.append("-");
                break;
            case 4:
                out.append("#");
                break;
            default:
                out.append("?");
                break;
        }
        
        //out.append(modifiers + " ");
        out.append(name);
        
        return out.toString();
    }

    public static void main(String[] args) {
        new Main();
    }
}
